#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@Author  :   JingV
@Version :   1.0
@Contact :   None
@License :   None
@Desc    :   None
'''


class Solution(object):
    def combinationSum3(self, k, n):
        result = []

        def helper(cur_nums, left_num):
            len_nums, sum_nums = len(cur_nums), sum(cur_nums)
            if left_num > 10 or len_nums > k or sum_nums > n:
                return
            if len_nums == k:
                if sum_nums == n:
                    result.append(cur_nums)
                return

            helper(cur_nums + [left_num], left_num + 1)
            helper(cur_nums, left_num + 1)
        
        helper([], 1)
        return result



def main():
    solution = Solution()
    tests = [(3, 15), ]
    for k, n in tests:
        print(solution.combinationSum3(k, n))


if __name__ == "__main__":
    main()
